<link href="http://demo.swfupload.org/v220/css/default.css" />
<div>
    <div class="formTable">        
        <form action="/admini/managemystore/instore" method="post">            
            <table style="width:60%">
                <tr>
                    <th width="100px" class="w1" nowrap>仓库号：</th>
                    <td width="180px" nowrap>
                        <input type="hidden" id="ingstoreId" name="ingstoreId" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->id; ?>" />
                        <input type="text" id="storeno" name="storeno" style="width:143px" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->userinfo->storeno; ?>" />
                    </td>

                    <th width="100px" nowrap>预报序号：</th>
                    <td nowrap colspan="3">
                        <input type="text"  value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->id; else echo '0'; ?>" id="storeId" name="storeId" style="width:143px" />
                    </td>

                    <td rowspan="8" width="30%" nowrap>
                        <?= $this->formHidden('image', '/pic/wu40.png') ?>
                        <div class="fieldset flash" id="fsUploadProgress">
                            <span class="legend">Upload Queue</span>
                        </div>
                        <div id="divStatus">0 Files Uploaded</div>
                        <div>
                            <span id="stt"></span></br>
                            <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 29px;" />
                        </div>
                        <div style="position: absolute;margin-left:120px;margin-top:-100px">
                            <image id="pimage" src="/pic/wu40.png" />
                        </div>

                    </td>
                </tr>

                <tr>
                    <th nowrap>用户信息：</th>
                    <td colspan="5" nowrap>
                        <?php
                        if ($this->ingstoreItem) {
                            ?>
                            <span style="color:#000000" id="userinfo">帐号:<?php echo $this->ingstoreItem->userinfo->email; ?> 用户ID：<?php echo $this->ingstoreItem->userinfo->id; ?> 昵称:<?php echo $this->ingstoreItem->userinfo->nikename; ?></span>
                            <input type="hidden" id="userid" name="userid" value="<?php echo $this->ingstoreItem->userid; ?>"/>
                            <?php
                        } else {
                            ?>
                            <span style="color:#000000" id="userinfo">输入仓库号，将会自动加载用户信息</span>
                            <input type="hidden" id="userid" name="userid" value=""/>
                            <?php
                        }
                        ?>
                    </td>
                </tr>

                <tr>
                    <th nowrap>物流单号：</th>
                    <td colspan="5" nowrap>
                        <input type="text" id="logistics" name="logistics" style="width:143px" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->shipNo; ?>" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>物流公司：</th>
                    <td colspan="5" nowrap>
                        <input type="text" id="logisticName" name="logisticName" style="width:143px" value="<?php if ($this->ingstoreItem) echo $this->ingstoreItem->shipType; ?>" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>仓库条形码：</th>
                    <td colspan="5" nowrap>
                        <input type="text" id="barcode" name="barcode" style="width:143px" />
                    </td>
                </tr>

                <tr>
                    <th nowrap>体积：</th>
                    <td nowrap>
                        <input type="text" id="length" value="0" name="length" style="width:40px" />*<input type="text" value="0" id="width" name="width" style="width:40px" />*<input type="text" id="height" value="0" name="height" style="width:40px" />(cm)
                    </td>

                    <th nowrap>体积重量：</th>
                    <td nowrap>
                        <input type="text" id="volumeWeight" value="0" name="volumeWeight" style="width:50px" />(g)
                    </td>

                    <th nowrap>体积重量类型：</th>
                    <td nowrap>
                        <select id="bignessType" name="bignessType">
                            <option value="0" selected>普通</option>
                            <option value="1">轻抛</option>
                            <option value="2">抛</option>
                            <option value="3">重抛</option>
                        </select>
                    </td>
                </tr>

                <tr>
                    <th nowrap>物品重量：</th>
                    <td nowrap>
                        <input type="text" id="weight" name="weight" style="width:143px" />(g)
                    </td>

                    <th nowrap>去包重量：</th>
                    <td nowrap>
                        <input type="text" id="noPackageWeight" name="noPackageWeight" style="width:50px" />(g)
                    </td>

                    <th nowrap>真空后体积重量：</th>
                    <td nowrap>
                        <input type="text" id="vacuumWeight" name="vacuumWeight" style="width:50px" />(g)
                    </td>
                </tr>

                <tr>
                    <th nowrap>&nbsp;</th>
                    <td colspan="5" nowrap><label> <?= $this->formCheckbox('isPack') ?>是否有包装</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('canVacuum') ?>能否真空处理</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('isEmbargo') ?>是否禁运品</label>&nbsp;&nbsp;<label> <?= $this->formCheckbox('isSpecific') ?>是否特殊的</label></td>
                </tr>

                <tr>
                    <th nowrap>产品类型：</th>
                    <td colspan="5" nowrap nowrap><ul clas="itemtype">
                            <li><label><input type="radio" name="itemType" id="itemType1" value="1">仿牌</label></li>
                            <li><label><input type="radio" name="itemType" id="itemType2" value="2">电池</label></li>
                            <li><label><input type="radio" name="itemType" id="itemType4" value="4">液体</label></li>
                            <li><label><input type="radio" name="itemType" id="itemType8" value="8">食品</label></li>
                            <li><label><input type="radio" name="itemType" id="itemType16" value="16">粉未</label></li>                        
                            <li><label><input type="radio" name="itemType" id="itemType32" value="32">膏状物</label></li>                        
                            <li><label><input type="radio" name="itemType" id="itemType64" value="64">药物</label></li>                        
                            <li><label><input type="radio" name="itemType" id="itemType128" value="128">敏感</label></li>                        
                        </ul>
                    </td>                      
                    <td></td>
                </tr>

                <tr>
                    <th nowrap>包裹清单：</th>
                    <td colspan="6" nowrap>
                        <textarea id="productName" name="productName" style="width:99%" rows="5"><?php if ($this->ingstoreItem) echo $this->ingstoreItem->name; ?></textarea>
                    </td>
                </tr>  

                <tr height="2px">
                    <th>&nbsp;</th>
                    <td colspan="6">
                        &nbsp;
                    </td>
                </tr> 

                <tr>
                    <th nowrap>备注：</th>
                    <td colspan="6">
                        <textarea id="remark" name="remark" style="width:99%" rows="5"><?php if ($this->ingstoreItem) echo $this->ingstoreItem->remark; ?></textarea>
                    </td>
                </tr>
            </table>
            <div>
                <input type="submit" onclick="return checkForm();" value="确认发货">                
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="http://demo.swfupload.org/v220/swfupload/swfupload.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/swfupload.queue.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/handlers.js"></script>
<script type="text/javascript" src="http://demo.swfupload.org/v220/simpledemo/js/fileprogress.js"></script>
<script>
    $(function(){
        $('#storeno').change(function(){
            $.post('/admini/managemystore/userinfo', {'storeno':$(this).val()}, function(data){
                if(!data){
                    $('#userinfo').text('没有找到该仓库号对应的用户信息');
                    alert('没有找到该仓库号对应的用户信息,请检查仓库号是否输入正确');
                    $('#storeno').focus();
                    return;
                }
                $('#userid').val(data.userid);
                $('#userinfo').text('帐号:'+data.email+' 用户ID：'+data.userid+' 昵称:'+data.nikeName);
            }, 'json');
        });
        $('form').validate();
        
        $('#length').change(function(){
            var length = parseFloat($('#length').val());
            if(typeof(length) == 'NaN')
                length = 0;
            var width = parseFloat($('#width').val());
            if(typeof(width) == 'NaN')
                width = 0;
            var height = parseFloat($('#height').val());
            if(typeof(height) == 'NaN')
                height = 0;

            $('#volumeWeight').val(length*width*height/5000);
        });
        $('form').validate();
        
        $('#width').change(function(){
            var length = parseFloat($('#length').val());
            if(typeof(length) == 'NaN')
                length = 0;
            var width = parseFloat($('#width').val());
            if(typeof(width) == 'NaN')
                width = 0;
            var height = parseFloat($('#height').val());
            if(typeof(height) == 'NaN')
                height = 0;
            
            $('#volumeWeight').val(length*width*height/5000);
        });
        $('form').validate();
        
        $('#height').change(function(){
            var length = parseFloat($('#length').val());
            if(typeof(length) == 'NaN')
                length = 0;
            var width = parseFloat($('#width').val());
            if(typeof(width) == 'NaN')
                width = 0;
            var height = parseFloat($('#height').val());
            if(typeof(height) == 'NaN')
                height = 0;
            
            $('#volumeWeight').val(length*width*height/5000);
        });
        $('form').validate();
    });
    
    function checkForm(){
        if($('#storeno').val() == ""){
            alert("请输入仓库号");
            return false;
        }
        
        if($('#userid').val() == ""){
            alert("用户不存在，请输入正确的仓库号");
            return false;
        }
  
        if($.trim($('#productName').val()) == ""){
            alert("请输入包裹清单");
            return false;
        }
        
        return true;
    }
</script>
<script type="text/javascript">
    var swfu;

    window.onload = function() {
        var settings = {
            flash_url : "/js/swfupload/swfupload.swf",
            upload_url: "/ajax/upload",
            post_params: {"PHPSESSID" : ""},
            file_size_limit : "100 MB",
            file_types : "*.jpeg;*.png;*.jpg;*.gif",
            file_types_description : "图片文件",
            file_upload_limit : 100,
            file_queue_limit : 0,
            custom_settings : {
                progressTarget : "fsUploadProgress",
                cancelButtonId : "btnCancel"
            },
            debug: false,

            // Button settings
            button_image_url: "/images/share/button.gif",
            button_width: "65",
            button_height: "29",
            button_placeholder_id: "stt",
            button_text: '<span class="theFont">上传图片</span>',
            button_text_style: ".theFont { font-size: 16; }",
            button_text_left_padding: 12,
            button_text_top_padding: 3,
				
            // The event handler functions are defined in handlers.js
            file_queued_handler : fileQueued,
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_start_handler : uploadStart,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : function(file,data){
                        
                $('#image').val('/'+$.parseJSON(data));
                $('#pimage').attr('src',$('#image').val());
                var progress = new FileProgress(file, this.customSettings.progressTarget);
                progress.setComplete();
                progress.setStatus("Complete.");
                progress.toggleCancel(false);
            },
            //upload_success_handler : uploadSuccess,
            upload_complete_handler : uploadComplete,
            queue_complete_handler : queueComplete	// Queue plugin event
        };

        swfu = new SWFUpload(settings);
    };
</script>